#!/usr/bin/env ruby

tool = 'mp3unicode -s GBK -1 UTF-8 -p'
list = `find . -name '*.mp3'`.split("\n")
total = list.size
success = 0
exceptions = {}
list.each do |file|
  puts "Processing #{file} ..."
  output = `#{tool} '#{file}' 2>&1`
  if $?.success?
    success += 1
  else
    exceptions[file] = output
  end
end

puts "\nErrors:"
exceptions.each {|f,e| puts "[#{f}] #{e}"}
puts "\nSuccess: #{success} Failed: #{exceptions.size} Total: #{total}"
